

/*---------------------------------------------------------
   Initializes the effect. The data is a table of data 
   which was passed from the server.
---------------------------------------------------------*/
function EFFECT:Init( data )
	
	self.Ent = data:GetEntity()
	if self.Ent == nil or self.Ent == NULL then return end
	self.Pos = data:GetOrigin()
	self.DieTime = CurTime() + 12
	self.Velocity 	= Vector( 0, 0, 1 )
	
	self.Emitter = ParticleEmitter( self.Pos )
	
end


/*---------------------------------------------------------
   THINK
   Returning false makes the entity die
---------------------------------------------------------*/
function EFFECT:Think( )
	if self.Ent == nil or self.Ent == NULL then 
		if self.Emitter then
			self.Emitter:Finish()
		end
	return false end
	if not self.Ent:Alive() then self.Emitter:Finish() return false end
	if self.DieTime < CurTime() then self.Emitter:Finish() return false end

		for i=1,math.random(1,3) do
			self.Pos = self.Ent:GetPos() + Vector(math.random(-50,50),math.random(-50,50),0)
			local particle = self.Emitter:Add( "effects/yellowflare", self.Pos )
	
			particle:SetVelocity( self.Velocity * math.Rand( 30, 60 ) )
			particle:SetDieTime( 2.2 )
			particle:SetStartAlpha( math.random( 200, 240 ) )
			particle:SetEndAlpha( 0 )
			particle:SetStartSize( 1.4 )
			particle:SetEndSize( 0 )
			particle:SetRoll( math.Rand( 0, 360 ) )
			particle:SetRollDelta( math.Rand( -0.1, 0.1 ) )
			particle:SetColor( 50, math.random(100,150), 220 )
			particle:VelocityDecay( false )
		
			particle:SetCollide( true )
			particle:SetBounce( .99 )
			
			local dir = (self.Ent:GetPos() - self.Pos):Normalize()
			local ang = dir:Angle() + Angle(0,90,0)
			local vec = ang:Forward()
			vec = vec:Normalize() * 70
			
			particle:SetGravity( Vector( vec.x, vec.y, 0 ) )
		end
	
	return true
end


/*---------------------------------------------------------
   Draw the effect
---------------------------------------------------------*/
function EFFECT:Render()

	// Do nothing - this effect is only used to spawn the particles in Init
	
end



